import React from 'react'
import { useLocation,Navigate } from 'react-router-dom'
function Hoc_login(Com) {
  return function Fn () {
    let location=useLocation()
    let bailist=['/login','/404']
    let flag=bailist.includes(location.pathname)
    let token=localStorage.getItem('token')
    if(flag){
        return <Navigate to={location.pathname}></Navigate>
    }else{
        if(token){
            return <Com></Com>
        }else{
            return <Navigate to={'/login'}></Navigate>
        }
    }
  }
}

export default Hoc_login
